package bitWork;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: tao
 * Date: 2023-12-09
 * Time: 14:11
 */
public class Work1 {
    public static void main(String[] args) {
        //奇数位于偶数之前
        int[] arr = {1,2,3,4,5,6};
        int head = 0;
        int tail = arr.length - 1;
        while (head < tail) {
            while (arr[head] % 2 == 1) {
                head++;
            }
            while (arr[tail] % 2 == 0) {
                tail--;
            }
            if(head < tail) {
                int tmp = arr[head];
                arr[head] = arr[tail];
                arr[tail] = tmp;
                head++;
                tail--;
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
